
$(function(){
	var page_width = $(window).width();
	var post_left = (Number(page_width)-300)/2;
	$("#tool").css("margin-left",post_left+"px");
	
});

//上传
function upload_pic(k){	
	 $.ajaxFileUpload({
	     url: 'index.php?do=board&view=index&ajax=upload_file&k='+k,
	     fileElementId: 'upload_file_'+k,
	     dataType: 'json',
	     success: function(json){
	    	 if (json.status == "1"){
	   	           $("#td_"+k).html('<input type="hidden" name="ad['+k+'][ad_pic]" value="'+json.data+'"><img src="../'+json.data+'">');
	   	         }else{
	   	      		art.dialog({content:'图片上传失败'});
	     		}
	 		}
 	});
	
}

//添加列表
function add_item(){
	var k = $("#k").val();
		k = Number(k)+1;
	$.get('index.php?do=board&view=index&ajax_tpl=board_index&k='+k,function (text){
		$("#t_body").append(text);
		$("#k").val(k);
	},'text');	
}

function sbt(){
	$("#pic_form").submit();
}
//预览
function preview(){
	art.dialog.open("index.php?do=pic_view&ad_code=index",{
		lock:true,
		title:"图片轮播",
		height:'220px'
	}, false);
}

function slt_url(i){	
	
	var art_url = $("#slt_"+i).val();
	if(art_url=="custom"){
		$("#ad_url_"+i).val("");
		$("#show_custom_"+i).show();
	}else{
		$("#ad_url_"+i).val(art_url);
		$("#show_custom_"+i).hide();
		
	}	
}

function del_item(obj){
	$(obj).parent().parent().remove();
	
}

